Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add doorbell #30

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
Open

Add doorbell #30

wants to merge 7 commits into from

Conversation

th0m4sek
Copy link
Collaborator

Changes tested and working ok.

@@ -82,6 +82,10 @@ void kitchenOff() {
setOutput(KITCHEN_TABLE_ID, Relay::OFF);
}

void doorbellclick() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s use camelCase naming with callback for callback functions, ie:
‘doorbellClickCallback’

@@ -82,6 +82,10 @@ void kitchenOff() {
setOutput(KITCHEN_TABLE_ID, Relay::OFF);
}

void doorbellclick() {
dzwonek=1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For enumerated values Enum can be proposed based on CPP code style guidelines:
‘’’
enum DoorBellState
{
DISABLED = 0,
ENABLED = 1,
SWITCHED = 2,
}
‘’’
See ‘Relay’ enum.

@@ -15,6 +15,8 @@
#define MY_BAUD_RATE 115200
#endif

uint8_t dzwonek = 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer English language for variable names: ‘doorbellState‘

@@ -120,4 +124,6 @@ void setupButtons() {
workshop.attachClick(clickCallback, WORKSHOP_ID);

corridor.attachClick(clickCallback, CORRIDOR_ID);

doorbell.attachPressStart(doorbellclick);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use camelCase for callback as mentioned above.

@@ -71,6 +73,21 @@ void loop() {
kitchenTable.tick();
workshop.tick();
corridor.tick();
doorbell.tick();

switch (dzwonek) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Switch can be encapsulated in function (ie: ‘updateDoorbellState’) to avoid too long implementation of ‘loop’ and additionally it will automatically explain it’s purpose.
  2. As the current code doesn’t have any validation in any other places, it’s good practice to add implementation of default behaviour, even if it will never fall into it and there will be only ‘break’ instruction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants